package org.kazuhiko.rpg.server.model;

public abstract class Entity
{
	private int id;
	private int oldId;
	
	private Position position;
	private Position oldPosition;
	
	private Rotation rotation;
	private Rotation oldRotation;
	
	private String name;
	
	public Entity()
	{
		//Chilling
	}
	
	public int getId()
	{
		return id;
	}
	
	public void setId( int id )
	{
		oldId = this.id;
		this.id = id;
	}
	
	public int getOldId()
	{
		return oldId;
	}
	
	public Position getPosition()
	{
		if( position == null )
		{
			position = new Position();
		}
		
		return position;
	}
	
	public void setPosition( Position position )
	{
		oldPosition = this.position;
		this.position = position;
	}
	
	public Position getOldPosition()
	{
		if( oldPosition == null )
		{
			return getPosition();
		}
		
		return oldPosition;
	}
	
	public Rotation getRotation()
	{
		if( rotation == null )
		{
			rotation = new Rotation();
		}
		
		return rotation;
	}
	
	public void setRotation( Rotation rotation )
	{
		oldRotation = this.rotation;
		this.rotation = rotation;
	}
	
	public Rotation getOldRotation()
	{
		if( oldRotation == null )
		{
			return getRotation();
		}
		
		return oldRotation;
	}
	
	public String getName()
	{
		return name;
	}
	
	public void setName( String name )
	{
		this.name = name;
	}
	
	public void resetToOldPosition()
	{
		position = oldPosition;
	}
	
	public void resetToOldRotation()
	{
		rotation = oldRotation;
	}
}
